package logic

import (
	"context"
	"weee/orderrpc/orderrpcclient"

	"weee/api/internal/svc"
	"weee/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodsShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsShowLogic {
	return &GoodsShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GoodsShowLogic) GoodsShow(req *types.GoodsShowRequest) (resp *types.GoodsShowResponse, err error) {
	// todo: add your logic here and delete this line
	res, _ := l.svcCtx.OrderRpc.GoodsShow(l.ctx, &orderrpcclient.GoodsShowRequest{})
	if res.Code != 200 {
		return &types.GoodsShowResponse{
			Code: int(res.Code),
			Msg:  res.Msg,
		}, nil
	}
	return &types.GoodsShowResponse{
		Code: int(res.Code),
		Msg:  res.Msg,
		Data: res.Data,
	}, nil
}
